<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    //去重，用函数封装的方式
    function unique(arr) {
        var newArr = [];//新建一个空的数组来接收新的数组
        for (var i = 0;i < arr.lenght; i++){
            if (newArr.indexOf(arr[i]) === -1){
                newArr.push(arr[i]);
            }
        }
        return newArr;
    }
    var demo = unique([12,0,8,0,56,0,23,0]);
    console.log(demo);
</script>
<body>

</body>
</html>